package org.ypx.center.service.impl;

import org.springframework.stereotype.Service;
import org.ypx.center.service.IRoleRightService;
import org.ypx.db.entity.RolePermission;
import org.ypx.db.entity.UserRole;

/**
 * @author Yan Peixuan
 * @date 2017/3/28 20:45
 * @description
 */
@Service
public class RoleRightServiceImpl extends BaseServiceImpl<RolePermission> implements IRoleRightService {
    @Override
    public void correlationPermissions(Long roleId, Long... permissionIds) {
        RolePermission rolePermission = new RolePermission();
        rolePermission.setRoleId(roleId);
        this.delete(rolePermission);
        for (Long permissionId : permissionIds) {
            rolePermission.setPermissionId(permissionId);
            super.save(rolePermission);
        }
    }

}
